package com.yitao.cms.controller.product;

import com.skipper.base.bean.DataOutput;
import com.skipper.base.bean.PagedInput;
import com.skipper.base.bean.PagedOutput;
import com.yitao.cms.config.aopLog.LogAnnotation;
import com.yitao.cms.dto.product.ProductCommentDetailDto;
import com.yitao.cms.service.product.ProductCmsCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @Auther: wwl
 * @Date: 2019/3/11 0011 12:50
 * @Description:
 */
@Api(value = "/cms/productCmsComment", description = "商品评论相关接口", tags = {"cms-product-comment"})
@RestController
@RequestMapping(value = "/productCmsComment", produces = {"application/json"})
public class ProductCmsCommentController {
    @Autowired
    private ProductCmsCommentService productCmsCommentService;
    @ApiOperation("商品评论信息列表")
    @RequestMapping(value = "/findProductCommentList", method = RequestMethod.POST)
    public PagedOutput<ProductCommentDetailDto> findProductCommentList(HttpServletRequest request,
                                                                       @ApiParam(value = "商品名") @RequestParam(value = "productName", required = false) String productName,
                                                                       @ApiParam(value = "开始时间") @RequestParam(value = "staDate", required = false) String staDate,
                                                                       @ApiParam(value = "结束时间") @RequestParam(value = "endDate", required = false) String endDate,
                                                                       @ApiParam(value = "搜索") @RequestParam(value = "content", required = false) String content,
                                                                       @ApiParam(value = "昵称") @RequestParam(value = "nickName", required = false) String nickName,
                                                                       @ApiParam(value = "分页参数，表示当前页", required = true, defaultValue = "1") @RequestParam(value = "pageNo") Integer pageNo,
                                                                       @ApiParam(value = "分页参数，表示每页显示多少条记录", required = true, defaultValue = "10") @RequestParam(value = "pageSize") Integer pageSize) {

        return productCmsCommentService.findProductCommentList(request,productName,staDate,endDate,content,nickName,pageNo,pageSize);
    }
    @ApiOperation("商品评论信息删除")
    @LogAnnotation(targetType = "productCmsComment-Delete", remark = "商品评论信息删除")
    @RequestMapping(value = "/deleteProductCommentById", method = RequestMethod.POST)
    public DataOutput deleteProductCommentById(HttpServletRequest request,
                                               @ApiParam(value = "id") @RequestParam(value = "id") Long id) {

        return productCmsCommentService.deleteProductCommentById(request,id);
    }
    @ApiOperation("商品评论信息详情")
    @RequestMapping(value = "/getProductCommentDetailById", method = RequestMethod.POST)
    public DataOutput<ProductCommentDetailDto> getProductCommentDetailById(
                                               @ApiParam(value = "id") @RequestParam(value = "id") Long id) {

        return productCmsCommentService.getProductCommentDetailById(id);
    }
}
